import base from "./base/index.config";
import media from "./media/index.config";

export const ComponentConfigs = [base, media];
// const _arr: any = [];

// let index: number = 1;

// arr.forEach((val) => {
//   val.list.forEach((element: any) => {
//     const config: any = {};
//     for (const key in element.config) {
//       const _e = element.config[key];
//       config[key] = _e.value;
//     }
//     _arr.push({
//       ...element,
//       config,
//       id: index++,
//     });
//   });
// });
// console.log(_arr);
let index = 1;
export const getComponentConfig = (item) => {
  let config: any = {};
  ComponentConfigs.forEach((val) => {
    val.list.forEach((element: any) => {
      if (
        item.category === element.category &&
        element.type === item.component
      ) {
        const _config: any = {};
        for (const key in element.config) {
          const _e = element.config[key];
          _config[key] = _e.value;
        }
        config = {
          ...element,
          config: _config,
          id: index++,
        };
      }
    });
  });
  return config;
};
